<?php

$rfid_data = fopen("rfid_data", "w");
fwrite($rfid_data, "");
fclose($rfid_data);

$rfid_status = fopen("rfid_status", "w");
fwrite($rfid_status, "1");
fclose($rfid_status);

while(file_get_contents("rfid_status") != 0) {
	sleep(1);
	$data = file_get_contents("rfid_data");
	$regexp = explode("%",$data);
	//echo @$regexp[1];
	//echo @$regexp[3];
	//echo @$regexp[5];
	//$name = $regexp[1];
	//$var = preg_replace('/[^a-z\d_]/iu', '', $name);
	$arr = @array ('name'=>strval(trim($regexp[1])),'locker'=>intval($regexp[3]),'machine'=>intval($regexp[5]));
	
}

echo json_encode($arr);

?>